import React from 'react'
import Content from "./content";
import {connect, Provider} from 'react-redux';
import {store} from "./redux-store";
import {fetchColor, addColor} from './redux-action'

const mapStateToContentProps = (state) => (
    {
        data: state.contentReducer
    }
);
const mapDispatchToContentProps = (dispatch) => (
    {
        onAdd: (params) => (
            dispatch(addColor(params))
        ),
        dispatch: dispatch,
    }
);

const ContentDisplay = connect(mapStateToContentProps, mapDispatchToContentProps)(Content);

//色系管理
class ColorManagement extends React.Component {
    componentDidMount() {
        store.dispatch(fetchColor());
    }

    render() {
        return (
            <div style={{marginTop: 100}}>
                <ContentDisplay/>
            </div>
        )
    }
}

const WrappedColorManagement = () => (
    <Provider store={store}>
        <ColorManagement/>
    </Provider>
);

export default WrappedColorManagement;
